package com.lee.demo.ui.activity.picker;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.lee.demo.R;
import com.lee.demo.ui.activity.DialogActivity;
import com.lee.demo.widget.picker.AntFortuneLikeProvider;

import java.util.Arrays;

import cn.lee.cplibrary.picker.common.DialogConfig;
import cn.lee.cplibrary.picker.common.DialogStyle;
import cn.lee.cplibrary.picker.wheelpicker.OptionPicker;
import cn.lee.cplibrary.picker.wheelpicker.contract.OnOptionPickedListener;
import cn.lee.cplibrary.picker.wheelpicker.widget.LinkageWheelLayout;
import cn.lee.cplibrary.picker.wheelpicker.widget.OptionWheelLayout;
import cn.lee.cplibrary.picker.wheelview.widget.WheelView;
/**
 * 日期、省市区、日历、单项滚轮选择器
 * Create by ChrisLee on 2021-10-28
 */

public class PickerDemoActivity extends FragmentActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_picker_demo);
        WheelView wheelView = findViewById(R.id.wheel_view);
        wheelView.setData(Arrays.asList("111", "222", "333", "444", "555", "666", "777", "888", "999",
                "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg"));
        OptionWheelLayout optionWheelLayout = findViewById(R.id.wheel_option);
        optionWheelLayout.getWheelView().setData(Arrays.asList("aaa", "bbb", "ccc", "123", "xxx", "yyy", "zzz"));
        LinkageWheelLayout linkageWheelLayout = findViewById(R.id.wheel_linkage);
        linkageWheelLayout.setData(new AntFortuneLikeProvider());
    }

    private void startActivity(Class<?> cls) {
        startActivity(new Intent(this, cls));
    }

    public void onDialogStyle(View view) {
        OptionPicker picker = new OptionPicker(this);
        picker.setData("默认-屏幕底部弹窗", "样式1-屏幕底部弹窗", "样式2-屏幕底部弹窗", "样式3-屏幕中间弹窗");
        picker.setOnOptionPickedListener(new OnOptionPickedListener() {
            @Override
            public void onOptionPicked(int position, Object item) {
                switch (position) {
                    case 1:
                        DialogConfig.setDialogStyle(DialogStyle.One);
                        break;
                    case 2:
                        DialogConfig.setDialogStyle(DialogStyle.Two);
                        break;
                    case 3:
                        DialogConfig.setDialogStyle(DialogStyle.Three);
                        break;
                    case 0:
                    default:
                        DialogConfig.setDialogStyle(DialogStyle.Default);
                        break;
                }
            }
        });
        picker.show();
    }

    public void onDateTimePicker(View view) {
        startActivity(DateTimePickerActivity.class);
    }

    public void onSinglePicker(View view) {
        startActivity(SinglePickerActivity.class);
    }

    public void onLinkagePicker(View view) {
        startActivity(LinkagePickerActivity.class);
    }

    public void onAddressPicker(View view) {
        startActivity(AddressPickerActivity.class);
    }

    public void onCalendarPicker(View view) {
        startActivity(DialogActivity.class);
    }

}


